load("//tools/lint:lint.bzl", "add_lint_tests")
load(
    "//tools/skylark:drake_cc.bzl",
    "drake_cc_googletest",
    "drake_cc_library",
    "drake_cc_package_library",
)

package(default_visibility = ["//visibility:public"])

drake_cc_package_library(
    name = "estimators",
    visibility = ["//visibility:public"],
    deps = [
        ":kalman_filter",
        ":luenberger_observer",
    ],
)

drake_cc_library(
    name = "kalman_filter",
    srcs = ["kalman_filter.cc"],
    hdrs = ["kalman_filter.h"],
    deps = [
        ":luenberger_observer",
        "//math:continuous_algebraic_riccati_equation",
        "//math:discrete_algebraic_riccati_equation",
        "//systems/framework",
        "//systems/primitives:linear_system",
    ],
)

drake_cc_library(
    name = "luenberger_observer",
    srcs = ["luenberger_observer.cc"],
    hdrs = ["luenberger_observer.h"],
    deps = [
        "//common:default_scalars",
        "//systems/framework",
    ],
)

# === test/ ===

drake_cc_googletest(
    name = "kalman_filter_test",
    deps = [
        ":kalman_filter",
        "//common/test_utilities:eigen_matrix_compare",
    ],
)

drake_cc_googletest(
    name = "luenberger_observer_test",
    deps = [
        ":luenberger_observer",
        "//common:pointer_cast",
        "//common/test_utilities:eigen_matrix_compare",
        "//common/test_utilities:is_dynamic_castable",
        "//examples/pendulum:pendulum_plant",
        "//systems/framework/test_utilities:scalar_conversion",
        "//systems/primitives:linear_system",
    ],
)

add_lint_tests()
